package com.sl.au.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.EXDEAgingLedgerAddOrReduce;
import com.sl.au.entity.EXDEgetPayDetailHistoryWithContract;
import com.sl.au.repository.EXDEAgingLedgerAddOrReduceRepository;
import com.sl.au.service.EXDEAgingLedgerAddOrReduceService;
/**
 * 新增减账龄台帐
 */
@Service("EXDEAgingLedgerAddOrReduceService")
@Transactional
public class EXDEAgingLedgerAddOrReduceServiceImpl extends BaseServiceImpl implements EXDEAgingLedgerAddOrReduceService{
	@Autowired
	EXDEAgingLedgerAddOrReduceRepository exdeAgingLedgerAddOrReduceRepository;
	
	@Override
	public EXDEAgingLedgerAddOrReduceRepository getRepository() {
		// TODO Auto-generated method stub
		return this.exdeAgingLedgerAddOrReduceRepository;
	}
	/*
	 * 查询内容
	 * */
	@Override
	public List<EXDEAgingLedgerAddOrReduce> getMyPage(int start, int length, Map<String, String> condition) {
		// TODO Auto-generated method stub
		Page<EXDEAgingLedgerAddOrReduce> pages=null; 
		Pageable pageable=new PageRequest(start/length,length);
		if(condition.get("key") != null && !condition.get("key").toString().equals("")){
			pages = exdeAgingLedgerAddOrReduceRepository.findAllTrance(condition.get("superior"),condition.get("key"), pageable);
		}else{
			pages = exdeAgingLedgerAddOrReduceRepository.findAllTrance(condition.get("superior"),pageable);
		}
		//pages = exdegetPayDetailHistoryWithContractService.findAllTrance(condition.get("superior"),condition.get("sContractType"),pageable);
		return pages.getContent();
	}
	/*
	 * 查询数据条数
	 * */
	@Override
	public long getMyPageCount(int start, int length, Map<String, String> condition) {
		// TODO Auto-generated method stub
		long count = 0;
		if(condition.get("key") != null && !condition.get("key").equals("")){
			count = exdeAgingLedgerAddOrReduceRepository.findAllTrancegetCount(condition.get("superior"),condition.get("key"));
		}else{
			count = exdeAgingLedgerAddOrReduceRepository.findAllTrancegetCount(condition.get("superior"));
		}
		return count;
	}
}
